package ynu.edu.Service.Impl;

import io.micrometer.observation.annotation.Observed;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import ynu.edu.Dao.DeviceDao;
import ynu.edu.Dao.LightDao;
import ynu.edu.Entity.Device;
import ynu.edu.Entity.Light;
import ynu.edu.Service.ISensorService;

import java.util.Date;
import java.util.List;


@Service
public class LightService implements ISensorService {
    @Resource
    DeviceDao deviceDao;
    @Resource
    LightDao lightDao;
    @Override
    public void insert(Double value){
        Light light = new Light();
        Device device = deviceDao.getReferenceById(4L);
        light.setDevice(device);
        light.setValue(value);

        lightDao.save(light);
    }
    @Override
    public Double getValue(){
        Light light = lightDao.findFirstByOrderByCreateTimeDesc().get();
        return light.getValue();
    }
    @Override
    public List<Double> getValuesFromLastDay(){
        return null;
    }
    @Override
    public List<Date> getTimeFromLastDay(){
        return null;
    }
}
